<!--面试考核-->
<template>
  <div class="rightBodyContent">
    <div class="rightBodyContent-in">
      <el-tabs v-model="activeName" type="card" @tab-click="handleClick">
        <el-tab-pane :label="item.name" :name="item.id" v-for="item in tabList" :key="item.id"></el-tab-pane>
      </el-tabs>
      <!--本体列表，数据 -->
      <div class="table-body">
        <div class="table-body-box">
          <el-table
              ref="multipleTable"
              :data="arryList"
              :border="tableoption.tableBorder"
              tooltip-effect="dark">
            <el-table-column
                label="ID"
                align="center"
                prop="id">
            </el-table-column>
            <el-table-column
                label="算法名称"
                align="center"
                prop="name">
              <template slot-scope="scope">
                双亲
              </template>
            </el-table-column>
            <el-table-column
                label="操作"
                align="center"
                width="180">
              <template slot-scope="scope">
                <el-button size="small" @click="resumeVisible=true">编辑算法</el-button>
                <el-button size="small" @click="showDetail(scope.row.id)">删除</el-button>
              </template>
            </el-table-column>
          </el-table>
        </div>
      </div>
      <!--工具条 分页-->
      <el-col :span="24" class="toolbar">
        <el-pagination
            background
            :page-size="page.pagesize"
            :current-page="page.pageindex"
            layout="total, prev, pager, next"
            :total="page.total"
            @current-change="handleSizeChange"></el-pagination>
      </el-col>
    </div>
    <editPoint :visible.sync="resumeVisible"></editPoint>
  </div>
</template>

<script>
import {pagination, tableoption, yeartime} from '@/utils/util.js'
import editPoint from './edit'
export default {
  components: {
    editPoint
  },
  data() {
    return {
      tableList: [{name: '全部', id: 0}],
      tableoption: tableoption,
      tabList:[
        {
          name:'个性发展',
          id:1,
        },
        {
          name:'亲子背景',
          id:2
        },
        {
          name:'学习品质',
          id:3
        },
        {
          name:'专注力',
          id:4
        },
      ],
      page: {
        pageindex: pagination.pageIndex,
        pagesize: pagination.pageSize,
        total: pagination.total
      },
      first_id: '',
      arryList: [], // 数据列表
      // 搜索
      searchWord: '',
      searchCatId: 0,
      // 弹窗
      dialogVisible: false,
      editIndex: null,
      foodOption: '',
      dialogType: null,
      activeName: 1,
      activeNamechange: 'first',
      resumeVisible: false,
      resumeId: 0,
      numberList: [0, 0],
      searchForm: {
        job_id: '',
        name: ''
      },
      jobList:[]
    }
  },
  created() {
    this.JobFn()
    this.InitFn()
  },
  methods: {
    // 初始化
    async InitFn() {
      // <!--        resumeType 1 查看简历 2 待处理的简历 3 待面试简历 4 考核中的应聘者 5 一录用应聘者-->
      // p 	整型 	必填 	1 	- 	页码
      // rercuit_sn 	字符串 	必填 	1 	- 	招聘发布编号
      // title 	字符串 	必填 	1 	- 	招聘名称
      // name 	字符串 	必填 	1 	- 	面试人
      // mobile_phone 	字符串 	必填 	1 	- 	面试人电话
      // status 	字符串 	必填 	1 	- 	0待审核1通过2驳回
      // recruit_id
      // statuss 0 简历待审核 1 待面试 2 简历驳回不符合 3 面试淘汰 4 考核中 5 录用 6 考核不通过 7 离职中 8 离职通过 9 离职驳回
      // 0 简历待处理 1 历史审核记录 2 面试待处理 3 面试历史 4 录用待处理 5 录用历史
      let option = {
        p: this.page.pageindex,
        status: 1,
        type: this.activeName === 'first' ? 2 : 3,
        name: this.searchForm.name,
        job_id: this.searchForm.job_id,
      };
      console.log('option:', option)
      let data = await this.$fetch(this.api.recruit.vitae.index, option);
      console.log('data:', data)
      if (!data.code) {
        for (let i in data.list.data) {
          data.list.data[i].create_time = data.list.data[i].create_time.split(' ')[0]
        }
        this.arryList = data.list.data
        this.page.total = data.list.total
        this.numberList = this.getJson(data.number)
      }
    },
    getJson(option) {
      return JSON.parse(JSON.stringify(option))
    },
    cateListFn() {
      this.$fetch(this.api.cate_list, {
        p: 1
      }).then((response) => {
        if (response.code === 0) {
          for (let i in response.list.data) {
            this.tableList.push(response.list.data[i])
          }
        } else {
        }
      }).catch((err) => {
        console.log(err)
      })
    },
    // 分页
    handleSizeChange(val) {
      this.page.pageindex = val
      this.InitFn()
    },
    showDetail(id) {
      this.resumeId = id
      this.resumeVisible = true
    },
    handleClick(tab, event) {
      if (this.activeName !== this.activeNamechange) {
        this.activeNamechange = this.activeName;
        this.page.pageindex = 1
        this.arryList = []
        this.InitFn()
      }
    },
    // 获取岗位信息
    async JobFn() {
      let data = await this.$fetch(this.api.recruit.job.index, {p: 1});
      this.jobList = data.list.data;
    },
    searchFn(option) {
      if (option === 'refresh') {
        this.searchForm.name = ''
        this.searchForm.job_id = ''
      }
      this.page.pageindex = 1;
      this.InitFn()
    }
  },
  mounted() {
  }
}
</script>
